package com.ruoyi.web.controller.exam;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.exam.domain.PExamNum;
import com.ruoyi.exam.domain.PExamNumb;
import com.ruoyi.exam.service.IPExamNumbService;
import com.ruoyi.exam.service.IPExamService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 默认考试数量Controller
 *
 * @author jiadun
 * @date 2022-01-05
 */
@RestController
@RequestMapping("/system/numb")
public class PExamNumbController extends BaseController
{
    @Autowired
    private IPExamNumbService pExamNumbService;

//    @Autowired

    /**
     * 查询默认考试数量列表
     */
//    @PreAuthorize("@ss.hasPermi('system:numb:list')")
    @GetMapping("/list")
    public TableDataInfo list()
    {
        startPage();
        List<PExamNum> list = pExamNumbService.selectPExamNumList();
        return getDataTable(list);
    }

    /**
     * 导出默认考试数量列表
     */
//    @PreAuthorize("@ss.hasPermi('system:numb:export')")
    @Log(title = "默认考试数量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PExamNumb pExamNumb)
    {
        List<PExamNumb> list = pExamNumbService.selectPExamNumbList(pExamNumb);
        ExcelUtil<PExamNumb> util = new ExcelUtil<PExamNumb>(PExamNumb.class);
        util.exportExcel(response, list, "默认考试数量数据");
    }

    /**
     * 获取默认考试数量详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:numb:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(pExamNumbService.selectPExamNumById(id));
    }


    /**
     * 修改默认考试数量
     */
//    @PreAuthorize("@ss.hasPermi('system:numb:edit')")
    @Log(title = "默认考试数量", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PExamNum pExamNum)
    {
        return toAjax(pExamNumbService.updatePExamNum(pExamNum));
    }

    /**
     * 删除默认考试数量
     */
//    @PreAuthorize("@ss.hasPermi('system:numb:remove')")
    @Log(title = "默认考试数量", businessType = BusinessType.DELETE)
	  @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable("ids") Long[] ids)
    {
        return toAjax(pExamNumbService.deletePExamNumByIds(ids));
    }

    /**
     * 新增默认考试数量
     */
//    @PreAuthorize("@ss.hasPermi('system:numb:add')")
    @Log(title = "默认考试数量", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult addT(@RequestBody PExamNum pExamNum)
    {
      return toAjax(pExamNumbService.insertPExamNumb(pExamNum));
    }
}
